package dao;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;

import model.Opinion;

import com.util.SqlMapLocator;




public class OpinionDao {
	private static OpinionDao singleton;
	private OpinionDao(){

	}
	public static OpinionDao getInstance(){
		if(singleton == null){
			singleton = new OpinionDao();
		}
		return singleton;
	}


	/**
	 * 意見追加
	 * @param paraMap
	 * @throws SQLException
	 */
	public void regist(HashMap<String, Object> paraMap) throws SQLException {
		SqlMapLocator.getMapper().insert("opinion.regist", paraMap);
	}

	/**
	 * 意見インデックス取得
	 * @return
	 * @throws SQLException
	 */
	public Integer selectId() throws SQLException{
		SqlMapLocator.getMapper().update("opinion.updateseq");
		return (Integer) SqlMapLocator.getMapper().queryForObject("opinion.selectseq");
	}

	/**
	 * 意見リスト取得
	 * @return
	 * @throws SQLException
	 */

	@SuppressWarnings("unchecked")
	public List<Opinion> getList(HashMap<String, Object> paraMap) throws SQLException {
		return SqlMapLocator.getMapper().queryForList("opinion.list", paraMap);
	}

	/**
	 * 意見カウンタ増加
	 * @param paraMap
	 * @throws SQLException
	 */
	public void addCounter(HashMap<String, Object> paraMap) throws SQLException{
		SqlMapLocator.getMapper().update("opinion.addcounter", paraMap);
	}

	/**
	 * 意見リスト取得
	 * @param paraMap
	 * @return
	 * @throws SQLException
	 */
	@SuppressWarnings("unchecked")
	public List<Opinion> getSearchList(HashMap<String, Object> paraMap) throws SQLException{
		return SqlMapLocator.getMapper().queryForList("opinion.searchlist", paraMap);
	}

}
